package com.qianniu.napi.admin.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.qianniu.napi.admin.entity.Category;
import com.qianniu.napi.admin.entity.Permission;
import com.qianniu.napi.admin.mapper.CategoryMapper;
import com.qianniu.napi.admin.mapper.PermissionMapper;
import com.qianniu.napi.admin.service.ICategoryService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chenxuebin
 * @since 2017-11-10
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements ICategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public Page<Category> selectCatePage(Page<Category> page,int pid) {

//        page.setRecords(categoryMapper.selectList(page,pid));.eq("pid", pid)
        EntityWrapper ew = new EntityWrapper<Category>();
        ew.where("LEVEL={0}","1").isNull("pid");
        System.out.println(">>>"+ew.getSqlSegment());

        page.setRecords(categoryMapper.selectList(page,ew));

        return page;
    }

}
